home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / lib / include / sys / RCS / shm.h,v < prev    next >
Text File  |  1990-02-20  |  6KB  |  223 lines

  1. head     1.1;
  2. branch   ;
  3. access   ;
  4. symbols  ;
  5. locks    ; strict;
  6. comment  @ * @;
  7.  
  8.  
  9. 1.1
  10. date     90.02.19.23.48.31;  author jhh;  state Exp;
  11. branches ;
  12. next     ;
  13.  
  14.  
  15. desc
  16. @@
  17.  
  18.  
  19.  
  20. 1.1
  21. log
  22. @Initial revision
  23. @
  24. text
  25. @/*     @@(#)shm.h    4.1.1.2    (ULTRIX)    12/9/88     */
  26.  
  27. /************************************************************************
  28.  *                                    *
  29.  *            Copyright (c) 1986 by                *
  30.  *        Digital Equipment Corporation, Maynard, MA        *
  31.  *            All rights reserved.                *
  32.  *                                    *
  33.  *   This software is furnished under a license and may be used and    *
  34.  *   copied  only  in accordance with the terms of such license and    *
  35.  *   with the  inclusion  of  the  above  copyright  notice.   This    *
  36.  *   software  or  any  other copies thereof may not be provided or    *
  37.  *   otherwise made available to any other person.  No title to and    *
  38.  *   ownership of the software is hereby transferred.            *
  39.  *                                    *
  40.  *   This software is  derived  from  software  received  from  the    *
  41.  *   University    of   California,   Berkeley,   and   from   Bell    *
  42.  *   Laboratories.  Use, duplication, or disclosure is  subject  to    *
  43.  *   restrictions  under  license  agreements  with  University  of    *
  44.  *   California and with AT&T.                        *
  45.  *                                    *
  46.  *   The information in this software is subject to change  without    *
  47.  *   notice  and should not be construed as a commitment by Digital    *
  48.  *   Equipment Corporation.                        *
  49.  *                                    *
  50.  *   Digital assumes no responsibility for the use  or  reliability    *
  51.  *   of its software on equipment which is not supplied by Digital.    *
  52.  *                                    *
  53.  ************************************************************************/
  54. /*
  55.  *
  56.  *   Modification history:
  57.  *
  58.  * 3 Mar 88 -- jaa
  59.  *    added smsmat to sminfo, which is now the configurable
  60.  *    highest attachable address for shared mem
  61.  *
  62.  * 27 Jan 87 -- depp
  63.  *    Cleaned up some of the incompatibilities between SYSTEM V and
  64.  *    ULTRIX-32 naming conventions
  65.  *
  66.  * 29 Apr 86 -- depp
  67.  *    Moved some shared memory constants from param.h to here, except 
  68.  *    SMMIN, SMMAX, SMBRK which are configurable.  The defaults
  69.  *    for these 3 constants is in /sys/conf/param.c.  Plus, the data
  70.  *    element "small" removed from struct sminfo.
  71.  *
  72.  * 18 Mar 86 -- depp
  73.  *    Changed struct smem.  The sm_daddr member is now a pointer rather
  74.  *    than an array, so that an array can be dynamically allocated to
  75.  *    handle any size request.
  76.  *
  77.  * 18 Sep 85 -- depp
  78.  *    Added SMNOSW flag and sm_lcount for page locking
  79.  *
  80.  * 08 April 85 -- depp
  81.  *    New file for System V shared memory
  82.  *
  83.  */
  84.  
  85. /*
  86. **    IPC Shared Memory Facility.
  87. */
  88.  
  89. /*
  90. **    Implementation Constants.
  91. */
  92.  
  93.             /* segment low boundary address multiple */
  94.             /* (SMLBA must be a power of 2) */
  95. #ifdef vax
  96. #define    SMLBA    ctob(CLSIZE)
  97. #endif vax
  98. #ifdef mips
  99. #define SMLBA   ctob(NPTEPG)
  100. #endif mips
  101.  
  102.  
  103.             /* for SYSTEM V compatibility        */
  104. #define    SHMLBA        SMLBA
  105.  
  106. /*
  107. **    Permission Definitions.
  108. */
  109.  
  110. #define    SM_R    0400    /* read permission */
  111. #define    SM_W    0200    /* write permission */
  112.  
  113.             /* for SYSTEM V compatibility        */
  114. #define SHM_R    SM_R
  115. #define SHM_W    SM_W
  116.  
  117. /*
  118. **    ipc_perm Mode Definitions.
  119. */
  120.  
  121. #define    SM_CLEAR    01000    /* clear segment on next attach */
  122. #define    SM_DEST        02000    /* destroy seg when # attached = 0 */
  123.  
  124.             /* for SYSTEM V compatibility        */
  125. #define SHM_INIT    SM_CLEAR
  126. #define SHM_DEST    SM_DEST
  127.  
  128. /*
  129. **    Message Operation Flags.
  130. */
  131.  
  132. #define    SM_RDONLY    010000    /* attach read-only (else read-write) */
  133. #define    SM_RND        020000    /* round attach address to SHMLBA */
  134.  
  135.             /* for SYSTEM V compatibility        */
  136. #define SHM_RDONLY    SM_RDONLY
  137. #define SHM_RND        SM_RND
  138.  
  139. /*
  140.  *  sizing constant (the balance are in /sys/h/param.h and /sys/conf/param.c.
  141.  */
  142. #define    SMMNI    100       /* Max number SM segments in system */
  143.  
  144. /*
  145. **    Structure Definitions.
  146. */
  147.  
  148.  
  149. /*
  150. **    There is a shared mem id struct for each segment in the system.
  151. */
  152.  
  153.  
  154. struct smem {
  155.                 /* SM_PERM must be the first    */
  156.                 /* element in the structure.    */
  157.     struct ipc_perm    sm_perm;    /* permission struct */
  158.     swblk_t    *sm_daddr;     /* disk addrs of DMTEXT page segs */
  159.     swblk_t    sm_ptdaddr;    /* disk address of page table */
  160.     size_t    sm_size;    /* segment size (bytes) */
  161.     struct proc *sm_caddr;    /* ptr to linked proc, if loaded */
  162.     struct pte *sm_ptaddr;    /* ptr to assoc page table */
  163.     short    sm_rssize;    /* SM resource set size (pages)    */
  164.     ushort sm_lpid;        /* pid of last smop */
  165.     ushort sm_cpid;        /* pid of creator */
  166.     char    sm_count;    /* reference count */
  167.     char    sm_ccount;    /* number of loaded references */
  168.     short    sm_lcount;    /* number of processes locking SMS */
  169.     short    sm_flag;    /* traced, written flags */
  170.     short    sm_poip;    /* page out in progress count */
  171.     time_t    sm_atime;    /* last smat time */
  172.     time_t    sm_dtime;    /* last smdt time */
  173.     time_t    sm_ctime;    /* last change time */
  174. };
  175.             /* for SYSTEM V compatibility        */
  176. #define shmid_ds    smem
  177. #define key_t        long
  178. #define shm_perm    sm_perm
  179. #define shm_segsz    sm_size
  180. #define shm_cpid    sm_cpid
  181. #define shm_lpid    sm_lpid
  182. #define shm_nattch    sm_count
  183. #define shm_atime    sm_atime
  184. #define shm_dtime    sm_dtime
  185. #define shm_ctime    sm_ctime
  186.  
  187.  
  188. /* NOTE:  These values must align with X* flag values in text.h */
  189. #define    SMLOCK    010        /* Being swapped in or out */
  190. #define    SMWANT    020        /* Wanted for swapping */
  191. #define SMNOSW    0100        /* Lock segment in memory */
  192.  
  193. /* shared memory specific commands for shmctl syscall */
  194. #define SHM_LOCK    3    /* Lock segment in memory */
  195. #define SHM_UNLOCK    4    /* Unlock segment in memory */
  196.  
  197. /*
  198.  * sminfo structure is used by the system for bounds checking.  All of 
  199.  * the elements in this structure are initialized in /sys/conf/param.c.
  200.  *
  201.  * Three of the elements are configurable via the "config" program
  202.  * (smmax, smmin, smbrk).  If they are not config'ed, then they all
  203.  * have defaults.
  204.  */  
  205. struct sminfo {
  206.     int    smmax,    /* max shared memory segment size */
  207.         smmin,    /* min shared memory segment size */
  208.         smmni,    /* # of shared memory identifiers */
  209.         smseg,    /* max attached shared memory segs per proc */
  210.         smbrk,    /* gap (in clicks) used between data and SM */
  211.             smsmat; /* max shmem attach addr (clicks) */
  212. };
  213.  
  214.             /* for SYSTEM V compatibility */
  215. #define shminfo        sminfo
  216. #define shmmax        smmax
  217. #define shmmin        smmin
  218. #define shmmni        smmni
  219. #define shmseg        smseg
  220. #define shmbrk        smbrk
  221.  
  222. @
  223.